package com.gc.business.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gc.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import com.gc.business.mapper.AnnualPlanMapper;
import com.gc.business.domain.AnnualPlan;
import com.gc.business.service.IAnnualPlanService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;

/**
 * 电梯年检计划 服务层实现
 * 
 * @author hruiyan
 * @date 2020-12-01
 */
@Slf4j
@Service
public class AnnualPlanServiceImpl extends ServiceImpl<AnnualPlanMapper, AnnualPlan> implements IAnnualPlanService {

    @Override
    public List<AnnualPlan> list(AnnualPlan annualPlan){
        LambdaQueryWrapper<AnnualPlan> wrapper = new LambdaQueryWrapper<>();
        if(annualPlan != null){
            if(StringUtils.isNotEmpty(annualPlan.getPlanId())){
                wrapper.eq(AnnualPlan::getPlanId, annualPlan.getPlanId());
            }
            if(StringUtils.isNotEmpty(annualPlan.getElevatorId())){
                wrapper.eq(AnnualPlan::getElevatorId, annualPlan.getElevatorId());
            }
            if(StringUtils.isNotEmpty(annualPlan.getElevatorName())){
                wrapper.like(AnnualPlan::getElevatorName, annualPlan.getElevatorName());
            }
            if(StringUtils.isNotEmpty(annualPlan.getRegisteredCode())){
                wrapper.eq(AnnualPlan::getRegisteredCode, annualPlan.getRegisteredCode());
            }
            if(StringUtils.isNotEmpty(annualPlan.getInstallationDate())){
                wrapper.eq(AnnualPlan::getInstallationDate, annualPlan.getInstallationDate());
            }
            if(StringUtils.isNotEmpty(annualPlan.getAnnualDate())){
                wrapper.eq(AnnualPlan::getAnnualDate, annualPlan.getAnnualDate());
            }
            if(StringUtils.isNotEmpty(annualPlan.getSpeedGovernor())){
                wrapper.eq(AnnualPlan::getSpeedGovernor, annualPlan.getSpeedGovernor());
            }
            if(StringUtils.isNotEmpty(annualPlan.getCreateBy())){
                wrapper.eq(AnnualPlan::getCreateBy, annualPlan.getCreateBy());
            }
            if(StringUtils.isNotEmpty(annualPlan.getCreateTime())){
                wrapper.eq(AnnualPlan::getCreateTime, annualPlan.getCreateTime());
            }
            if(StringUtils.isNotEmpty(annualPlan.getUpdateBy())){
                wrapper.eq(AnnualPlan::getUpdateBy, annualPlan.getUpdateBy());
            }
            if(StringUtils.isNotEmpty(annualPlan.getUpdateTime())){
                wrapper.eq(AnnualPlan::getUpdateTime, annualPlan.getUpdateTime());
            }
            if(StringUtils.isNotEmpty(annualPlan.getRemark())){
                wrapper.eq(AnnualPlan::getRemark, annualPlan.getRemark());
            }
        }
        return baseMapper.selectList(wrapper);
    }


    /**
     * 数据权限查询 --公司
     * @param annualPlan
     * @return
     */
    @Override
    public List<AnnualPlan> selectAnnualPlanList(AnnualPlan annualPlan){
        return baseMapper.selectAnnualPlanList(annualPlan);
    }


    /**
     * 根据电梯ID查询对应年检计划
     * @param elevatorId
     * @return
     */
    @Override
    public AnnualPlan selectByElevatorId(Long elevatorId){
        return baseMapper.selectByElevatorId(elevatorId);
    }
}
